package com.loongtech.bi.manager.pay;

import java.util.Date;
import java.util.List;

import org.springframework.stereotype.Service;

import com.loongtech.bi.entity.pay.EntityActiveUserFirstAddcashDaySection;
import com.loongtech.core.jpa.manager.ManagerQueryCacheBase;
import com.loongtech.core.util.Time;

@Service
public class ActiveUserFirstAddcashDaySectionManager extends ManagerQueryCacheBase<EntityActiveUserFirstAddcashDaySection> {
	private static final long serialVersionUID = 1L;
	
	/**
	 * 根据开始结束时间，求DAU
	 * @param dateStart
	 * @param dateEnd
	 * @param type
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public List<Object[]> getFirstAddcashDayByAllKind(Date dateStart, Date dateEnd, String queryPlatform, String queryChannel, String queryServer) {
		return getSession().createSQLQuery("select SUBSTRING_INDEX(day_section,'_',-1),sum(user_number) from active_user_first_addcash_day_section  where 1=1 and day>= '"+Time.getDateStr(dateStart) +"' and day<= '"+Time.getDateStr(dateEnd)+"' and platformid = '"+queryPlatform+"' and channelid = '"+queryChannel+"' and serverid = '"+queryServer+"' group by day_section order by CAST(SUBSTRING_INDEX(day_section,'_',1) AS SIGNED) asc").list();
	}
}
